package cate.game.role.res;

import cate.common.game.GameCollection;
import cate.game.res.hoard.Hoard;
import cate.game.res.lubiitem.LubiItem;
import cate.game.res.revelry.RevelryDraw;
import cate.game.role.Role;
import cate.game.role.RolePart;
import cate.game.role.res.achievement.RoleAchievement;
import cate.game.role.res.adverttisement.RoleWatchAdvertisement;
import cate.game.role.res.call.CallPO;
import cate.game.role.res.channelgift.RoleChannelGift;
import cate.game.role.res.compose.ComposePO;
import cate.game.role.res.cross_sync.RoleCrossSync;
import cate.game.role.res.crystalldraw.MyCrystallDraw;
import cate.game.role.res.expire.RoleExpireNotice;
import cate.game.role.res.farm.MyFarms;
import cate.game.role.res.findback.RoleFindBack;
import cate.game.role.res.forge.RoleForge;
import cate.game.role.res.formations.RoleFormations;
import cate.game.role.res.furniturecall.FurnitureCall;
import cate.game.role.res.goldmall.po.GoldMall;
import cate.game.role.res.guild.po.my.MyGuildPO;
import cate.game.role.res.hero.introduction.HeroIntroduction;
import cate.game.role.res.hero.reborn.HeroReborn;
import cate.game.role.res.holy_pet.RoleHolyPet;
import cate.game.role.res.inscription.RoleInscription;
import cate.game.role.res.kingsacrifice.RoleKingSacrifice;
import cate.game.role.res.leader.RoleLeader;
import cate.game.role.res.magiccontract.RoleMagicContract;
import cate.game.role.res.racebadge.RaceBadges;
import cate.game.role.res.rune.RoleRune;
import cate.game.role.res.spicecall.SpiceCall;
import cate.game.role.res.treasureturntable.MyTreasureTurntables;
import cate.game.role.res.worldtree.WorldTree;
import easy.java.dev.note.NoteField;
import org.springframework.data.mongodb.core.mapping.Document;

@Document(value = GameCollection.NAME_ROLE_RES)
public class RoleRes extends RolePart {
    @NoteField(value = "召唤")
    public CallPO callPO;

    @NoteField(value = "重生")
    public HeroReborn reborn;

    @NoteField(value = "英雄共享")
    public WorldTree worldTree;

    @NoteField(value = "徽章")
    public RoleRune rune;

    @NoteField(value = "图鉴")
    public HeroIntroduction heroIntroduction;

    @NoteField(value = "主角")
    public RoleLeader leader;

    @NoteField(value = "族徽")
    public RaceBadges raceBadge;

    @NoteField(value = "协会")
    public MyGuildPO guild;

    @NoteField(value = "手办召唤")
    public FurnitureCall furnitureCall;

    @NoteField(value = "占星")
    public SpiceCall spiceCall;

    @NoteField(value = "渠道礼包")
    public RoleChannelGift channelGift;

    @NoteField(value = "合成")
    public ComposePO composePO;

    @NoteField("资源找回")
    public RoleFindBack findBack;

    @NoteField("过期提醒")
    public RoleExpireNotice expireNotice;

    @NoteField("金币商店")
    public GoldMall goldMall;

    @NoteField("寻宝转盘")
    public MyTreasureTurntables treasureTurntables;

    @NoteField("我的农场")
    public MyFarms farm;

    @NoteField("铭文")
    public RoleInscription inscription;

    @NoteField("水晶珍藏")
    public MyCrystallDraw crystallDraw;

    @NoteField("阵型")
    public RoleFormations formations;

    @NoteField("成就")
    public RoleAchievement achievement;

    @NoteField("灵王祭祀")
    public RoleKingSacrifice kingSacrifice;

    @NoteField("跨服同布")
    public RoleCrossSync crossSync;

    @NoteField("灵契台")
    public RoleMagicContract magicContract;
    @NoteField("广告")
    public RoleWatchAdvertisement watchAdvertisement;

    @NoteField("灵宠")
    public RoleHolyPet holyPet;
    @NoteField("装备一键合成上限")
    public RoleForge forge;
    @NoteField("鲁比的宝藏")
    public LubiItem lubiItem;

    @NoteField("百抽狂欢")
    public RevelryDraw revelryDraw;

    @NoteField("灵界秘藏")
    public Hoard hoard;

    public RoleRes() {
    }

    public RoleRes(Role role) {
        super(role);
    }

    @Override
    public void initialize(Role role) {
        super.initialize(role);
        if (callPO == null) {
            callPO = new CallPO();
        }
        callPO.initialize(role);
        if (reborn == null) {
            reborn = new HeroReborn();
        }
        reborn.initialize(role);
        if (rune == null) {
            rune = new RoleRune();
        }
        rune.initialize(role);
        if (heroIntroduction == null) {
            heroIntroduction = new HeroIntroduction();
        }
        heroIntroduction.initialize(role);
        if (leader == null) {
            leader = new RoleLeader();
        }
        leader.initialize(role);
        if (raceBadge == null) {
            raceBadge = new RaceBadges();
        }
        raceBadge.initialize(role);
        if (guild == null) {
            guild = new MyGuildPO();
        }
        guild.initialize(role);
        if (furnitureCall == null) {
            furnitureCall = new FurnitureCall();
        }
        furnitureCall.initialize(role);
        if (spiceCall == null) {
            spiceCall = new SpiceCall();
        }
        spiceCall.initialize(role);
        if (worldTree == null) {
            worldTree = new WorldTree();
        }
        worldTree.initialize(role);
        if (channelGift == null) {
            channelGift = new RoleChannelGift();
        }
        channelGift.initialize(role);
        if (composePO == null) {
            composePO = new ComposePO();
        }
        composePO.initialize(role);
        if (findBack == null) {
            findBack = new RoleFindBack();
        }
        findBack.initialize(role);
        if (expireNotice == null) {
            expireNotice = new RoleExpireNotice();
        }
        expireNotice.initialize(role);
        if (goldMall == null) {
            goldMall = new GoldMall();
        }
        goldMall.initialize(role);
        if (treasureTurntables == null) {
            treasureTurntables = new MyTreasureTurntables();
        }
        treasureTurntables.initialize(role);
        if (farm == null) {
            farm = new MyFarms();
        }
        farm.initialize(role);
        if (inscription == null) {
            inscription = new RoleInscription();
        }
        inscription.initialize(role);
        if (crystallDraw == null) {
            crystallDraw = new MyCrystallDraw();
        }
        crystallDraw.initialize(role);
        if (formations == null) {
            formations = new RoleFormations();
        }
        formations.initialize(role);
        if (achievement == null) {
            achievement = new RoleAchievement();
        }
        achievement.initialize(role);
        if (kingSacrifice == null) {
            kingSacrifice = new RoleKingSacrifice();
        }
        kingSacrifice.initialize(role);
        if (crossSync == null) {
            crossSync = new RoleCrossSync();
        }
        crossSync.initialize(role);
        if (magicContract == null) {
            magicContract = new RoleMagicContract();
        }
        magicContract.initialize(role);
        if (watchAdvertisement == null) {
            watchAdvertisement = new RoleWatchAdvertisement();
        }
        watchAdvertisement.initialize(role);
        if (holyPet == null) {
            holyPet = new RoleHolyPet();
        }
        holyPet.initialize(role);
        if (forge == null) {
            forge = new RoleForge();
        }
        forge.initialize(role);
        if (lubiItem == null) {
            lubiItem = new LubiItem();
        }
        lubiItem.initialize(role);
        if (revelryDraw == null) {
            revelryDraw = new RevelryDraw();
        }
        revelryDraw.initialize(role);
        if (hoard == null) {
            hoard = new Hoard();
        }
        hoard.initialize(role);
    }

    @Override
    public void onDaySpan(boolean silence) {
        checkOpen();
        reborn.onDaySpanSafe(silence);
        worldTree.onDaySpanSafe(silence);
        furnitureCall.onDaySpanSafe(silence);
        guild.onDaySpanSafe(silence);
        callPO.onDaySpanSafe(silence);
        spiceCall.onDaySpanSafe(silence);
        channelGift.onDaySpanSafe(silence);
        composePO.onDaySpan(silence);
        findBack.onDaySpanSafe(silence);
        treasureTurntables.onDaySpanSafe(silence);
        farm.onDaySpanSafe(silence);
        crystallDraw.onDaySpanSafe(silence);
        kingSacrifice.onDaySpan(silence);
        watchAdvertisement.onDaySpanSafe(silence);
        holyPet.onDaySpanSafe(silence);
        lubiItem.onDaySpanSafe(silence);
        revelryDraw.onDaySpanSafe(silence);
        hoard.onDaySpanSafe(silence);
    }

    @Override
    public void onWeekSpan(boolean silence) {
        guild.onWeekSpan();
        channelGift.onWeekSpanSafe(silence);
        composePO.onWeekSpanSafe(silence);
        holyPet.onWeekSpanSafe(silence);
    }

    @Override
    public void onMonthSpan(boolean silence) {
        callPO.onMonthSpanSafe(silence);
        channelGift.onMonthSpanSafe(silence);
        composePO.onMonthSpanSafe(silence);
    }

    public void checkOpen() {
        worldTree.checkOpen();
        leader.checkOpen();
        raceBadge.checkOpen();
        furnitureCall.checkOpen();
        guild.checkGuild();
        spiceCall.checkOpen();
        farm.checkOpen();
        inscription.checkOpen();
        formations.checkOpen();
        achievement.checkOpen();
        magicContract.checkOpen();
        watchAdvertisement.checkOpen();
        holyPet.checkOpen();
        forge.checkOpen();
        revelryDraw.checkOpen();
        hoard.checkOpen();
    }

    @Override
    public void onEnter() {
        checkOpen();
        //世界之树的checkOpen有依赖,放这里
        worldTree.onEnter();
        guild.onEnter();
        leader.onEnter();
        callPO.onEnter();
        spiceCall.onEnter();
        channelGift.onEnter();
        furnitureCall.onEnter();
        treasureTurntables.onEnter();
        farm.onEnter();
        inscription.onEnter();
        formations.onEnter();
        achievement.onEnter();
        kingSacrifice.onEnter();
        heroIntroduction.onEnter();
        magicContract.onEnter();
        crossSync.onEnter();
        holyPet.onEnter();
        revelryDraw.onEnter();
        hoard.onEnter();
    }

    public void tick() {
        farm.tick();
        leader.tick();
        crossSync.tick();
    }

    @Override
    public void offline() {
        guild.offlineSafe();
        watchAdvertisement.offlineSafe();
    }
}
